<template>
	<el-dialog
		:title="`德州俱乐部保险分成`"
		:visible="visible"
		width="750px"
		class="rempadding"
		:destroy-on-close="true"
		:before-close="handleClose"
		@close="handleClose"
	>
		<el-table
			v-loading="loading"
			element-loading-spinner="el-icon-loading"
			size="mini"
			class="small-size-table"
			:data="tableData"
			style="width: 100%;"
			:header-cell-style="getRowClass"
			highlight-current-row
			border
		>
			<el-table-column min-width="120" align="center" label="项目">
				德州保险
			</el-table-column>
			<el-table-column
				prop="userName"
				align="center"
				label="会员保险输赢"
				min-width="200"
			>
				<template slot-scope="scope">
					{{ handleTotalNumber('USDT', scope.row.validBetAmount) }}
				</template>
			</el-table-column>
			<el-table-column
				prop="userName"
				align="center"
				label="团队分成比例"
				min-width="120"
			>
				<template slot-scope="scope">
					{{ handlePercentage(scope.row.teamPartsRate) }}
				</template>
			</el-table-column>
			<el-table-column
				align="center"
				label="德州保险分成"
				min-width="200"
			>
				<template slot-scope="scope">
					{{ handleTotalNumber('USDT', scope.row.incomeAmount) }}
				</template>
			</el-table-column>
		</el-table>
	</el-dialog>
</template>

<script>
import list from '@/mixins/list'

export default {
	mixins: [list],
	props: {
		isDetail: {
			type: Boolean,
			default: false
		},
		curData: {
			type: Object,
			default: () => {}
		},
		orderNo: {
			type: String,
			default: ''
		},
		visible: {
			type: Boolean,
			default: false
		},
		handleVisible: {
			type: Object,
			default: () => {}
		}
	},
	data() {
		return {
			loading: false,
			tableData: [],
			dialogVisible: false
		}
	},
	created() {
		if (!this.isDetail) {
			this.getTableData()
		} else {
			this.formatTableData(this.curData)
		}
	},
	methods: {
		getTableData() {
			this.loading = true
			this.tableData = []
			this.$api
				.getProxyCommissionCashDetail({ id: this.orderNo })
				.then((res) => {
					this.loading = false
					this.formatTableData(res?.data)
				})
				.catch(() => {
					this.loading = false
				})
		},
		formatTableData(res) {
			const arr = res?.fundsAuditDetailRespList || []
			const item = arr.find((item) => item.rebateType === 2)
			if (item) {
				this.tableData = [item]
			}
		},
		handleClose() {
			this.$emit('update:visible', false)
		}
	}
}
</script>
